import 'package:flutter_kit_dsp/flutter_kit_dsp.dart';
import 'package:flutter_kit_plus/flutter_kit.dart';

import '../../common/unit_btn.dart';
import '../../tool/assets.dart';

class EqBottom extends StatefulWidget {
  const EqBottom({super.key});
  @override
  State<EqBottom> createState() => _EqBottomState();
}

class _EqBottomState extends State<EqBottom> {
  @override
  void initState() {
    super.initState();
  }

  Widget buildMyTextButton(
      {required String text,
      double width = 120,
      double radius = 4,
      Color? color,
      List<Color> colors = const [Color(0xFF9ED1E6), Color(0xFF9ED1E6)],
      required VoidCallback onTap}) {
    return myTextButton(
        width: width,
        radius: radius,
        color: color,
        colors: colors,
        onTap: onTap,
        child: Center(
            child: FittedBox(
          fit: BoxFit.scaleDown,
          child: Text(text, style: fontNormal),
        )));
  }

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.only(top: 10),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          const SizedBox(width: 50),
          Flexible(
            flex: 1,
            child: Column(
              children: [
                Expanded(
                    child: buildMyTextButton(
                        text: 'RESET ALL',
                        color: Color_yellow,
                        colors: [Color_yellow, Colors.white.withOpacity(0.2)],
                        onTap: () => globalController.resetEQ())),
                const SizedBox(height: 2),
                Expanded(child: Obx(() {
                  var text = globalController.byPassStatus.value == EQBypassStatus.restore ? 'RESTORE' : 'BYPASS';
                  var color = globalController.byPassStatus.value == EQBypassStatus.bypass
                      ? const Color(0xFF7BB254)
                      : const Color(0xFFCC4849);
                  return buildMyTextButton(
                      text: text,
                      color: color,
                      colors: [color, Colors.white.withOpacity(0.2)],
                      onTap: () {
                        globalController.bypassEQ();
                      });
                })),
              ],
            ),
          ),
          const SizedBox(width: 10),
          const Flexible(flex: 4, child: UnitBar(title: 'EQ')),
          const SizedBox(width: 10),
          Flexible(
            flex: 1,
            child: Column(
              children: [
                Expanded(
                    child: buildMyTextButton(
                        text: 'RESET CH',
                        color: Color_yellow,
                        colors: [Color_yellow, Colors.white.withOpacity(0.2)],
                        onTap: () => globalController.resetEQ(all: false))),
                const SizedBox(height: 2),
                Expanded(
                    child: buildMyTextButton(
                        text: 'COPY',
                        color: const Color(0xFF7BB254),
                        colors: [const Color(0xFF7BB254), Colors.white.withOpacity(0.2)],
                        onTap: () {
                          globalController.pastChannel(context, 'EQ');
                        })),
              ],
            ),
          ),
          const SizedBox(width: 20)
        ],
      ),
    );
  }
}
